//打包优化配置
const path = require('path');
function resolve (dir) {
  return path.join(__dirname, '..', dir)
}
const HtmlWebpackPlugin = require('html-webpack-plugin')
const glob = require('glob')
const fs = require('fs')
const qs = require('qs')
const NODE_ENV = process.env.NODE_ENV

const appConfig={
  resolve:{
    extensions: ['.vue', '.js'],
    alias:{
      '@': resolve('src'),
    }
  },
  entry:{
    spa:resolve('src/entry/spa.js')
  },
  definePlugin:{
    'process.env.buildEnv':JSON.stringify(process.env.buildEnv),//dev、stg、prd
  },
  path: NODE_ENV === 'development' ? 'dist' : 'dist/base', // 打包发布目录
  drop_console: process.env.buildEnv === 'PRD', // 打开vconsole
  getHtmlConfigPlugin() {
    const chunks=Object.keys(this.entry)
    return [
      new HtmlWebpackPlugin({
        title:'ui搜索器',
        filename: resolve(path.join(this.path,'md5.html')),
        template: 'ejs-compiled-loader-webpack4!'+resolve('templates/'+('md5.js')),
        inject: false,
        chunks: chunks,
      }),
      new HtmlWebpackPlugin({
        title:'ui搜索器',
        filename: resolve(path.join(this.path,'index.html')),
        template: 'ejs-compiled-loader-webpack4!'+resolve('templates/'+('index.ejs')),
        inject: false,
        chunks: chunks,
      })
    ]
  }
}
module.exports = appConfig
